package com.nowcoder.community.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class CookieUtil {

    public static String getValue(HttpServletRequest request, String name) {
        //先判空
        if (request == null || name == null) {
            return null;
        }
        Cookie[] cookies = request.getCookies();
        if(cookies != null){
            for (Cookie c:cookies){
                if (c.getName().equals(name)){
                    return c.getValue();
                }
            }
        }
        return null;
    }


}
